Skip to content

feat: add pagination to miner PRs and issues endpoints#112

Closed
Kelvinchen03 wants to merge 2 commits into
entrius:testfrom
Kelvinchen03:feat/pagination-for-miner-pulls-and-issues
Closed

feat: add pagination to miner PRs and issues endpoints#112
Kelvinchen03 wants to merge 2 commits into
entrius:testfrom
Kelvinchen03:feat/pagination-for-miner-pulls-and-issues

Conversation

@Kelvinchen03
Copy link
Copy Markdown

Summary

Implements cursor-based pagination with hard result caps for the /miners/:githubId/pulls and /miners/:githubId/issues endpoints. Adds cursor and limit query parameters to prevent unbounded responses while maintaining backward compatibility. Results default to 50 per page with a maximum cap of 200.

Related Issues

Closes #100

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  1. Started dev server: npm run dev in d:/Projects/gittensor/das-github-mirror/packages/das

  2. Tested first page: GET /api/v1/miners/:githubId/pulls?limit=10

  • Returns ≤10 results with next_cursor field
  1. Tested pagination: GET /api/v1/miners/:githubId/pulls?cursor=&limit=10
  • No duplicate results between pages
  • Proper ordering by created_at DESC
  1. Tested limit cap: GET /api/v1/miners/:githubId/pulls?limit=500
  • Returns max 200 results (hard cap enforced)
  1. Tested backward compatibility: GET /api/v1/miners/:githubId/pulls
  • Works without pagination params, returns first 50 results
  1. Ran automated test script: node test-pagination.js
  • All pagination scenarios pass

Checklist

  • I have read the Contributing Guide
  • Code builds without errors
  • New and existing tests pass (if applicable)
  • Documentation updated (if applicable)
  • No unnecessary dependencies added

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label May 19, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pagination params on existing endpoints — close, but three blockers before this can merge:

  1. packages/das/src/api/miners/miners.service.ts — the cursor encodes the lowercased repo_full_name (SELECT aliases LOWER(p.repo_full_name) AS repo_full_name, and next_cursor is built from that alias), but the keyset predicate (p.repo_full_name < $4) and ORDER BY p.repo_full_name DESC compare against the raw column. Mixed-case repo names will skip or duplicate rows at page boundaries. Order and compare on LOWER(p.repo_full_name) consistently, or encode the raw value into the cursor.

  2. getPullRequests/getIssues — the bounded default (50 rows) is applied unconditionally. These endpoints are validator-facing and currently return all rows; flipping the default silently truncates what validators score on until they follow next_cursor. Gate the bounding behind MINERS_PAGINATION_ENABLED (default off) as the issue's Backward-compatibility section specifies.

  3. Remove the stray package-lock.json — it's empty ({"packages":{}}) and unrelated to this change.

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented May 29, 2026

Duplicate of #126 which is better scoped/implemented. Closing.

@anderdc anderdc closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagination for /miners/:githubId/pulls and /issues

2 participants